package com.clqteam.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import com.clqteam.model.Employee;
import com.clqteam.service.AddSupplierService;

import com.clqteam.serviceimpl.AddSupplierServiceImpl;

import com.clqteam.service.AddSupplierService;

import com.clqteam.serviceimpl.AddSupplierServiceImpl;
/**
 * 供应商信息增加的控制层
 * @author lxg
 *
 */
public class AddSupplierController extends HttpServlet{
	AddSupplierService as = new AddSupplierServiceImpl();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("utf8");
		req.setCharacterEncoding("utf8");
		PrintWriter pw=resp.getWriter();
		//获取文本框值
		String supName=req.getParameter("supName");
		
		String supContacts=req.getParameter("supContacts");
		
		String supPhone=req.getParameter("supPhone");
		
		String id=req.getParameter("eId");
		
		int eId=Integer.parseInt(id);
		
		//调用服务层的方法
		boolean b=as.insertSupplier(supName, supContacts, supPhone, eId);	
		//条件判断
		if(b=true){
			pw.write("1");
		}else{
			pw.write("0");
		}

		pw.flush();
		pw.close();
	}
}
